/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.techhighteam675.robot2012;

import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.Timer;

/**
 *
 * @author Noah Dove
 */
public class SpeedEncoder extends Encoder
{
	int previousValue;
	Timer rateTimer;
    
        public SpeedEncoder(int aModuleNumber, int aChannel, int bModuleNumber, int bChannel)
        {
            super(aModuleNumber, aChannel, bModuleNumber, bChannel);
            previousValue = get();
            rateTimer.reset();
            rateTimer.start();
    }

    double GetCorrectedRate()
    {
	 double t_rate = (get() - previousValue) / rateTimer.get();
	 
	 previousValue = get();
	 rateTimer.reset();
	 rateTimer.start();
	 
	 return t_rate;
    }

    double PIDGet()
    {
            return GetCorrectedRate();
    }

}